package collection
{
	import com.common.utils.HashMap;
	
	import data.ItemVO;
	import data.MapVO;
	import data.PlayerVO;
	
	import flash.xml.XMLNode;

	public class DataCollection
	{
		public static var config:String = "config/";
		public static var userName:String = ''; //用户名
		public static var mission:int = 1; //关卡
		public static var allMission:int = 2; //总关数
		public static var playerMoveDirection:int; //角色移动方向
		public static var userMoveLen:Number = 30; //user角色每次移动的距离
		public static var aiMoveLen:Number = 15; //AI角色每次移动的距离
		public static var LIFE:int = 3; //游戏的命数
		
		public static var gameStart:Boolean = true; //游戏是否已经开始
		public static var TWEENTIME:Number = 0.3;
		public static var AIRANGE:int = 3; //ai每次移动的最大Grid数,  在这个值内 1~? 内随机数
		
		
		
		//*********************************************************************//
		//*********************************************************************//
		/**
		 * 初始化角色 和 物品信息
		 * 
		 */		
		public static var hmRoles:HashMap;
		public static var hmItems:HashMap;
		public static function xmlRole(xmlString:String):void
		{
			hmRoles = new HashMap();
			hmItems = new HashMap();
			
			var xml:XML = new XML(xmlString);
			var p:PlayerVO;
			for each(var x:XML in xml['player'])
			{
				p = new PlayerVO(String(x.@id), String(x.@name), String(x.@bitmapClassname));
				
				hmRoles.put(p.id, p);
			}
			
			var i:ItemVO;
			for each(x in xml['item'])
			{
				i = new ItemVO(String(x.@id), String(x.@name), String(x.@bitmapClassname), int(x.@award), String(x.@buff));
				
				hmItems.put(i.id, i);
			}
		}
		
		
		/**
		 * 
		 * @param content
		 * 
		 */		
		public static var hmMap:HashMap;
		public static function xmlMap(xmlString:String):void
		{
			hmMap = new HashMap();
			
			var m:MapVO;
			var xml:XML = new XML(xmlString);
			for each(var x:XML in xml['map'])
			{
				m = new MapVO(String(x.@id), String(x.@bitmapClassName), int(x.@rowNum), int(x.@columnNum), int(x.@gridWidth), int(x.@gridHeight));
				m.setGridInfo(String(x), String(x.@fly), String(x.@itemsInfo));//配饰地格数据 ， 包括： 是否可通过 ， 是否是跳转点以及跳转到的地格index， 地格内的物品信息
				m.setPlayerInfo(String(x.@playerEnemy));
				hmMap.put(m.id, m);
			}
		}
	}
}

